<template>
	<view class="class-overview">
		<jhj-sort ref="sort" class="sort" :sortData="sortData" @click="sortDataContent"></jhj-sort>
		<view class="content">
			<you-scroll ref="scroll" :fetch="getJopData">
				<view class="look-jop-item" slot-scope="{row,index}" @click="getJopDetail(row,index)">
					<look-jop-list :item="row"></look-jop-list>
				</view>
			</you-scroll>
		</view>
	</view>
</template>

<script>
	import {
		getJobList,
	} from '@/static/js/api/jop.js';
	import request from '@/static/js/request.js'
	import LookJopList from './components/JobListItem.vue'
	import youScroll from '@/components/uni-list-scroll/you-scroll'
	import JhjSort from '@/components/jhj-sort/jhj-sort.vue'
	var self;
	export default {
		components: {
			LookJopList,
			youScroll,
			JhjSort
		},
		data() {
			return {
				sortData: [
					[{
						name: '全部',
						isCheck: true
					}, {
						name: '今日',
						isCheck: false
					}, {
						name: '近三天',
						isCheck: false
					}, {
						name: '近七天',
						isCheck: false
					}, {
						name: '近两周',
						isCheck: false
					}],
					[{
						name: '全部',
						isCheck: true
					}, {
						name: '个人',
						isCheck: false
					}, {
						name: '班组',
						isCheck: false
					}, {
						name: '企业',
						isCheck: false
					}],
					[{
						name: '全部',
						isCheck: true
					}, {
						name: '杂工',
						isCheck: false
					}, {
						name: '钢筋工',
						isCheck: false
					}, {
						name: '架子工',
						isCheck: false
					}]
				],
				selectName: "",
				timeData: "",
				workTypeName: "",
				searchKeyName: "",
			}
		},
		onLoad(option) {
			this.selectName = option.select;
			this.getSortList();
		},
		mounted() {
			self = this;

			let i2 = 0;
			self.sortData[1].forEach((item2, index2) => {
				if (self.selectName == item2.name) {
					i2 = index2
				} else {
					item2.isCheck = false;
				}
			})
			self.$refs.sort.changeData(1, i2);
			self.$refs.scroll.loadData();
			// self = this;
		},
		methods: {

			getSortList() {
				this.selectName = this.selectName.slice(0, 2)
				this.sortData[1].forEach((item, index) => {
					if (this.selectName == item.name) {
						item.isCheck = true;
					} else {
						item.isCheck = false;
					}
				})
			},
			sortDataContent(item, index, index2) {
				if (index == 0) {
					if (index2 == 0) {
						this.timeData = ""
					} else if (index2 == 1) {
						this.timeData = "1"
					} else if (index2 == 2) {
						this.timeData = "3"
					} else if (index2 == 3) {
						this.timeData = "7"
					} else if (index2 == 4) {
						this.timeData = "14"
					}
				} else if (index == 1) {
					if (index2 == 0) {
						this.selectName = ""
					} else if (index2 == 1) {
						this.selectName = "个人"
					} else if (index2 == 2) {
						this.selectName = "班组"
					} else if (index2 == 3) {
						this.selectName = "企业"
					}
				} else if (index == 2) {
					if (index2 == 0) {
						this.workTypeName = ""
					} else if (index2 == 1) {
						this.workTypeName = "杂工"
					} else if (index2 == 2) {
						this.workTypeName = "钢筋工"
					} else if (index2 == 3) {
						this.workTypeName = "架子工"
					}
				}
				this.$refs.scroll.loadData();
			},
			getJopData(pageIndex, pageSize) {
				return getJobList(pageIndex + 1, pageSize, self.searchKeyName, self.timeData, self.selectName, self.workTypeName).then(
					res => {
						return res.data;
					})
			},
			getJopDetail(item, index) {
				uni.navigateTo({
					url: `/pages/home/jop/GetJopDetail?id=${item.id}`
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	.class-overview {
		height: 100vh;
		position: relative;
		overflow: hidden;


		.sort {
			background: #FFFFFF;
		}

		.content {
			height: calc(100vh - 500rpx);
			background: #F4F5F9;

			.look-jop-item {
				background: #FFFFFF;
				margin-bottom: 20rpx;
				padding-top: 32rpx;
				padding-bottom: 12rpx;
			}
		}
	}
</style>
